package com.yl.pattern.behavioralmodel.interpreter;

/**
 * @Author 小羊
 * @Date 1/11/2024下午 8:49
 * @ClassName Variable
 * @Description Variable
 */
public class Variable extends AbstractExpression{
    /**
     * 声明存储变量名的成员变量
     */
    private String name;

    public Variable(String name) {
        this.name = name;
    }

    @Override
    public int interpret(Context context) {
        return context.getValue(this);
    }

    @Override
    public String toString() {
        return name;
    }
}
